<div class="row">
	    <?php
	    // echo "<pre>";
	    // print_r($listBid->result());
	    // echo "</pre>";
        if(isset($projectDetail) == TRUE)
            $project = $projectDetail->row();

	    	if($listBid -> num_rows() > 0){
	    		foreach ($listBid->result() as $item) {
	    ?>

	    		<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 wrap_container no-padding">
	    			<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 no-padding">
	    				<?php 
		      				$recommend = false;

		      				if($project->provider_rated == $item->user_rating ){
		      					$recommend = true;	
		      				}
		      				
		      				if($item->user_categories != ''){
			      				$userCategoryIds = explode(',', $item->user_categories);
			      				$categoryIds = explode(',', $project->project_categories);
			      				foreach($userCategoryIds as $cateId){
			      					if(in_array($cateId, $categoryIds)){
			      						$recommend = true;
			      						break;
			      					}else{
			      						$recommend = false;
			      					}
			      				}
		      				}
		      				
		      				if($project->locations != ''){
			      				$locations = explode(',', $project->locations);
			      				if(in_array($item->country_id, $locations)){
			      					$recommend = true;
			      				}else{
		      						$recommend = false;
		      					}
	      					}
		      				
		      				if($recommend){
	      					?>
		      				<span class="recomend">Recomend</span>
		      				<?php }?>

		                <a href="<?php echo site_url('programmer/viewProfile/'.$item->user_id);?>" title="<?php echo $item->user_name;?>">
		                	<img class="img-responsive avatar_bider" src="<?php if ($item->logo != '') echo uimage_url($item->logo); else echo image_default(); ?>">
		                </a>
	    			</div>
	    			<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 no-padding">
	                	<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 no-padding" style="line-height:35px">

	                		<div class="user-row">
	                			<span><?php echo $item->user_name;?></span>
	                			<span style="margin-right:10px"></span>
	                			<span><?php echo getNameLocation($item->city);?></span>
	                		</div>
	                		<div class="user-row">
	                        	<div class="text-left">
	                        		<input id="preview-user" value="<?php echo $item->user_rating;?>" type="number" data-star-captions="{}" data-default-caption="{rating}" disabled = "disabled" class="rating" min=0 max=5  data-size="xs" >
	                        	</div>
	                    	</div>
	                    	<div class="user-row">
	                    		<span><?php echo $item->num_reviews;?> reviews</span>
	                    	</div>
	                    	<div class="user-row">
	                    		<span>Tỉ lệ hoàn thành</span>
	                    		<span>90%</span>
	                    	</div>
	                    	<div class="user-row">
	                    		<span>Số job đã tham gia</span>
	                    		<span><?php echo getTotalProjectUserDone($item->user_id);?></span>
	                    	</div>
	                	</div>
	                </div>

	                <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 no-padding info-user-footer3">

	                	<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
	                		<div class="user-row" style="margin-top:5px">
	                			<span>*<?php echo count_days_before($item->bid_time,time());?></span>
	                		</div>
	                		<div class="user-row" style="min-height:95px;margin-top:10px">
	                			<span>
	                				<?php 
	                					if(strlen($item->bid_desc) > 100) 
	                						echo cutStringDes($item->bid_desc,170)."...<a class='see_more' data-content= '".$item->bid_desc."' >More</a>";
	                					else
	                						echo $item->bid_desc;
	                				?>
	                			</span>
	                		</div>
	                		<div class="user-row">
	                			<span>
	                				<button class="btn btn-md btn-primary btn-message" data-toggle="tooltip"
												data-placement="top" title="Chức năng đang hoàn thiện">Message</button>
	                			</span>
	                		</div>
	                	</div>
	                </div>

	                <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" style="line-height:40px">
	                	<div class="user-row about_employer">
		        			<span style="color:#22b78d"><?php echo '$'.$item->bid_amount;?></span>
		        		</div>
		        		<div class="user-row about_employer">
		        			<span><?php echo $item->bid_days;?></span>
		        			<span> days</span>
		        		</div>
		        		<?php
		        			//$this->session->unset_userdata("project_".$project_id);
		        			if($this->session->userdata("project_".$project_id)){
		        				$count = 0;
		        				$array = $this->session->userdata("project_".$project_id);
		        				foreach ($array as $value) {
		        					if($value['dev_id'] == $item->user_id)
		        						$count++;
		        				}
		        				
		        				if($count == 0){
		        			?>
		        				<div class="user-row">
		        					<a class="show-tooltip" style="display:none;" data-toggle="tooltip" data-placement="top" title="Đã được chọn vào shortlist"></a>
				        			<label style="cursor: pointer;">
				        				<input type="checkbox" name="rshortlist" id="rshorlits" data-pr-id = "<?php echo $item->project_id;?>" data-user-id = "<?php echo $item->user_id;?>"> Shortlist
				        			</label>
				        		</div>
		        			<?php	
		        				}else{
		        					// không hiện gì cả
		        			?>
		        					<div class="user-row">
					        			<label class="mauchu">
					        				<input type="checkbox" checked="checked" name="rshortlist" id="rshorlits" data-pr-id = "<?php echo $item->project_id;?>" data-user-id = "<?php echo $item->user_id;?>"> Shortlist
					        			</label>
					        		</div>
		        			<?php
		        				}
		        			}else{
		        			?>
		        				<div class="user-row">
		        					<a class="show-tooltip" style="display:none;" data-toggle="tooltip" data-placement="top" title="Đã được chọn vào shortlist"></a>
				        			<label style="cursor: pointer;">
				        				<input type="checkbox" name="rshortlist" id="rshorlits" data-pr-id = "<?php echo $item->project_id;?>" data-user-id = "<?php echo $item->user_id;?>"> Shortlist
				        			</label>
				        		</div>
		        			<?php	
		        			}
		        		?>
		        		
		        		<div class="user-row">
		        			<button type="button" class="btn btn-md btn_invite_dev btn-message" id="btn_invite_dev" data-href="<?php echo site_url("userList/inviteProgrammer/".$item->user_id)?>">Hire</button>			        			
		        		</div>
	                </div>
			    </div>

			    
	    <?php
	    		}
	    	}
	    ?>
</div>
<div class="text-right">
	<?php if(isset($pagination)) echo $pagination;?>
</div>

<script type="text/javascript">
//$(function () { $("[data-toggle='tooltip']").tooltip(); });
	$(document).ready(function(){
		$("input[type=checkbox][name=rshortlist]").change(function(){
			if($(this).is(':checked')){
				var user_id = $(this).attr('data-user-id');
				var pr_id = $(this).attr('data-pr-id');
				var url = "<?php echo site_url('project/shortlist');?>";
				var target = $(this).parent();
				$.ajax({
					type : "POST",
					url : url,
					data : ({pr_id : pr_id,user_id : user_id,flag: 1}),
					beforeSend : function(){
						//target.hide();
					},
					success: function(data){
						var res = $.parseJSON(data);
						if(res.status == "success"){
							//target.children().attr('disabled', true);
							target.addClass("mauchu");
							target.siblings().css("display","block");
							target.siblings().tooltip('show');
							setTimeout(function(){target.siblings().tooltip('hide')},1000);
							$("#shortlist").load("<?php echo base_url().'index.php/project/show_shortlist_tab/'.$project_id?>");
							//alert("Đã được chọn vào danh sách");
						}
					},
				})// end ajax
			}else{
				var user_id = $(this).attr('data-user-id');
				var pr_id = $(this).attr('data-pr-id');
				var url = "<?php echo site_url('project/shortlist');?>";
				var target = $(this).parent();
				$.ajax({
					type : "POST",
					url : url,
					data : ({pr_id : pr_id,user_id : user_id,flag: 0}),
					beforeSend : function(){
						//target.hide();
					},
					success: function(data){
						var res = $.parseJSON(data);
						if(res.status == "success"){
							target.removeClass("mauchu");
							$("#shortlist").load("<?php echo base_url().'index.php/project/show_shortlist_tab/'.$project_id?>");
							//alert("Đã được chọn vào danh sách");
						}
					},
				})// end ajax
			}
			
		})// end radio shortlist change

	    $("body").on('click','a.see_more',function(){
	    	var content = $(this).attr('data-content');
	    	$(this).parent().html(content);
	    })


	})
</script>

